-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automated open graph images for blog posts #582
base: main
Are you sure you want to change the base?
Conversation
0cc1090
to
3a611cf
Compare
1d3e0de
to
e655d08
Compare
.vscode/settings.json
Outdated
"deno.enable": true, | ||
"deno.unstable": true, | ||
"deno.enablePaths": ["netlify/edge-functions"] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit anti-pragmatic, but I do not like to check in editor specific config files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add them to .gitignore 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅 I meant your global .gitignore
src/composables/useOpenGraphImage.js
Outdated
|
||
const { title, image, authors } = openGraphImage | ||
|
||
const url = `/api/og?title=${title}${image ? `&imageUrl=${image.url}` : ''}${authors.length ? `&authors=${JSON.stringify(authors)}` : ''}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use withQuery
from ufo
to create this URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't seem to handle json very well, so it became this: https://github.com/voorhoede/voorhoede-website/pull/582/files#diff-d638ef46d91b5f3782a9f6bf0bbaf9b4d0806449ba02b60737bc839d79251f84R10-R13
Open for suggestions on how to fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah maybe we shouldn't pass JSON in a query parameter at all?
@@ -0,0 +1,18 @@ | |||
export function useOpenGraphImage(openGraphImage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this composable code to useSeoHead.
e655d08
to
9dc9ef4
Compare
91c6f68
to
8214925
Compare
8214925
to
2404ee6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvements! Once you're back from vacation let's chat about this en er een klap op geven :)
Maybe in another PR we can add some docs about pulling env vars from Netlify since we're using netlify dev now...
Changes
Stuff to consider
Example of generated image:
https://deploy-preview-582--voorhoede-website.netlify.app/api/og?title=Can%20AI%20generate%20illustrations%20in%20a%20custom%20style?&imageUrl=https://www.datocms-assets.com/6524/1677686010-ai_illustratie_robot_w_trans.png&authors=[{%22name%22:%22James%22,%22image%22:{%22url%22:%22https://www.datocms-assets.com/6524/1675178862-james.png%22}}]
on page: https://deploy-preview-582--voorhoede-website.netlify.app/en/blog/can-ai-generate-illustrations-custom-style/